class InstitutosController < ApplicationController
  # GET /institutos
  # GET /institutos.json
  def index
    @institutos = Instituto.all(:order => "nome")

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @institutos }
    end
  end

  # GET /institutos/1
  # GET /institutos/1.json
  def show
    @instituto = Instituto.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @instituto }
    end
  end

  # GET /institutos/new
  # GET /institutos/new.json
  def new
    @instituto = Instituto.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @instituto }
    end
  end

  # GET /institutos/1/edit
  def edit
    @instituto = Instituto.find(params[:id])
  end

  # POST /institutos
  # POST /institutos.json
  def create
    @instituto = Instituto.new(params[:instituto])

    respond_to do |format|
      if @instituto.save
        format.html { redirect_to @instituto, notice: 'Instituto was successfully created.' }
        format.json { render json: @instituto, status: :created, location: @instituto }
      else
        format.html { render action: "new" }
        format.json { render json: @instituto.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /institutos/1
  # PUT /institutos/1.json
  def update
    @instituto = Instituto.find(params[:id])

    respond_to do |format|
      if @instituto.update_attributes(params[:instituto])
        format.html { redirect_to @instituto, notice: 'Instituto was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @instituto.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /institutos/1
  # DELETE /institutos/1.json
  def destroy
    @instituto = Instituto.find(params[:id])
    @instituto.destroy

    respond_to do |format|
      format.html { redirect_to institutos_url }
      format.json { head :no_content }
    end
  end
end
